package top.yuyufeng.mbuy.enums;

/**
 * 使用枚举表诉常量数据字段
 * 0-已取消，10-未付款，20-已付款，40-已发货，
 * 50-交易成功，60-交易关闭
 */
public enum OrderStatusEnum {
    CANCELED(0, "已取消"),
    NOT_PAY(10, "未付款"),
    HAS_PAY(20, "已付款"),
    HAS_SEND(40, "已发货"),
    SUCCESS(50, "交易成功"),
    CLOSED(60, "交易关闭");

    private int key;

    private String value;

    OrderStatusEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public static OrderStatusEnum valueOf(int index) {
        for (OrderStatusEnum e : values()) {
            if (e.getKey() == index) {
                return e;
            }
        }
        return null;
    }
}
